<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .bg{
            background-color: pink;
        }
    </style>
</head>
<body>
    <script>
        //1.获取元素 获取的是tbody里面所有的行
        var trs=document.querySelector('tbody').querySelector('tr');
        //2.利用循环绑定注册事件
        for(var i=0;i<trs.length;i++){
            //3.鼠标经过事件 onmouseover
            trs[i].onmouseover=function(){
                this.className="bg";
            }
            //4.鼠标离开事件 onmouseout
            trs[i].onmouseout=function(){
                this.className="";
            }
        }
    </script>
</body>
</html>